<template>
	<view class="u-m-t-20">
		<u-cell-group>
			<u-cell-item title="还款提醒" :arrow="false">
				<b-select :list="repayAlertList" @confirm="alertConfirm" :default-value="alertDefaultValue" :title="repayAlertTitle" slot="right-icon">
				</b-select>
			</u-cell-item>
			<u-cell-item title="还款日为" :arrow="false">
				<b-select :list="repayTypeList" @confirm="typeConfirm" :default-value="typeDefaultValue" :title="repayTypeTitle" slot="right-icon">
				</b-select>
			</u-cell-item>
			<u-cell-item title="账单日消费算在本期" :arrow="false">
				<u-switch v-model="repayStartType"></u-switch>
			</u-cell-item>
		</u-cell-group>

		<view class="u-m-t-10 button-box">
			<u-button type="warning" @click="click">保存</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				repayAlert: 2,
				repayAlertTitle: "提前3天+当天提醒",
				repayAlertList: [],
				alertDefaultValue: [2],

				repayType: 0,
				repayTypeTitle: "固定日期",
				repayTypeList: [],
				typeDefaultValue: [0],

				repayStartType: false
			}
		},
		onLoad(query) {
			let repay = this.$api.getConfRepay();
			this.repayAlertList = repay.repay_alert;
			this.repayTypeList = repay.repay_type;
			this.repayStartType = repay.repay_start_type;
		},
		methods: {

			alertConfirm(e) {
				this.repayAlertTitle = e[0].label;
				this.repayAlert = e[0].value;
			},
			typeConfirm(e) {
				this.repayTypeTitle = e[0].label;
				this.repayType = e[0].value;
			},
			click() {
				uni.$emit('credit_adv',{
					"repayAlert": this.repayAlert,
					"repayType": this.repayType,
					"repayStartType": this.repayStartType
				});
				uni.navigateBack();
			}
		},
	}
</script>

<style lang="scss">
	.button-box {
		padding: 30rpx;
	}
</style>
